#!/bin/bash

# Test master transfer for crashed cluster

. ./common

for i in 0 1 2; do
    _start_sheep $i
done

_wait_for_sheep 3

# start Sheepdog with three nodes
_cluster_format

# kill all sheeps
nr=3
for i in 0 1 2; do
    _wait_for_sheep $nr $i
    _kill_sheep $i
    nr=$(($nr - 1))
done

# master transfer will happen once
for i in 1 0 2; do
    _start_sheep $i
    nr=$(($nr + 1))
    _wait_for_sheep $nr 1
done

_wait_for_sheep 3

echo check whether all nodes have the same cluster info
for i in 0 1 2; do
    $DOG cluster info -p 700$i | _filter_cluster_info
done
